package de.risk.web;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class WebUtil {

	public static String getStrFromUrl(String surl) {
		
		final String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12";
		String result = "";
		try {
			URL url = new URL(surl);
			URLConnection conn = url.openConnection();
				conn.addRequestProperty("User-Agent", userAgent);

			BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
			String str;
			StringBuilder builder = new StringBuilder(1024);
			while ((str = in.readLine()) != null) {
				builder.append(str);
				builder.append("\n");
			}
			in.close();
			
			result = builder.toString();
			
		} catch (MalformedURLException e) {
			System.out.println(e.getMessage());
		} catch (IOException e) {
			System.out.println(e.getMessage());
		}
		return result;
	}
	
}
